package pub.elephants.net;

import pub.elephants.net.client.ElephantsClient;
import pub.elephants.net.server.ElephantsServer;
import pub.elephants.socket.netty.client.NettyClient;
import pub.elephants.socket.netty.server.NettyServer;

public enum NetConnectionEnum {

    NETTY(NettyServer.class, NettyClient.class, true),
   ;

    public final Class<? extends ElephantsServer> serverClass;
    public final Class<? extends ElephantsClient> clientClass;
    public final boolean autoMatch;

    NetConnectionEnum(Class<? extends ElephantsServer> serverClass, Class<? extends ElephantsClient> clientClass, boolean prefer) {
        this.serverClass = serverClass;
        this.clientClass = clientClass;
        this.autoMatch = prefer;
    }

    public static NetConnectionEnum autoMatch(String name, NetConnectionEnum defaultEnum) {
        for (NetConnectionEnum item : NetConnectionEnum.values()) {
            if (item.autoMatch && item.name().equals(name)) {
                return item;
            }
        }
        return defaultEnum;
    }
}
